package com.tool.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import me.fangx.haorefresh.R;

/**
 * 类别顶部视图
 */

public class RecylerHeader extends LinearLayout {

    private Context context;
    private LinearLayout header_view_layout;

    public RecylerHeader(Context context) {
        super(context);
        this.context = context;
        initView(context);
    }

    /**
     * @param context
     * @param attrs
     */
    public RecylerHeader(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView(context);
    }

    public void initView(Context context) {
        setGravity(Gravity.CENTER);
        setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        LayoutInflater layoutInflater = LayoutInflater.from(context);
        View view = layoutInflater.inflate(R.layout.header_layout, null);
        header_view_layout = (LinearLayout) view.findViewById(R.id.header_view_layout);

        addView(view);
    }


    //设置底部加载中效果
    public void addHeaderView(View view) {
        header_view_layout.removeAllViews();
        header_view_layout.addView(view);
    }

    public void setVisible() {
        setVisibility(VISIBLE);
        header_view_layout.setVisibility(VISIBLE);
    }


    public void setGone() {
        setVisibility(GONE);
    }

}